package com.aclever.sys.logic;

import com.aclever.resouces.SiteDB;
import com.aclever.resouces.SiteTableModel;
import com.aclever.resouces.Sitebean;
import com.aclever.sys.Parser;

import javax.swing.table.TableModel;
import java.io.IOException;

/**
 * Model v 0.1
 *
 */

public class ModelParser {
    private Parser parser = null;
    private TableModel siteTableModel;
    private SiteDB siteDB;
    Thread secondThread = null;

    public ModelParser(Parser parser){
        this.parser = parser;


    try {
            siteDB = new SiteDB();
        } catch (IOException e) {
        System.out.println("error in Model");
        }
            siteTableModel = new SiteTableModel(siteDB);



    }



    public synchronized void parseAllSites(){




        secondThread = new Thread(new Runnable() {



            @Override
            public void run() {

                parser.getView().progressBar.setIndeterminate(true);

                try {
                    parser.getView().siteTable.setModel(new SiteTableModel(new SiteDB()));
                } catch (IOException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }



                parser.getView().progressBar.setIndeterminate(false);
            }
        });


        secondThread.start();





     }


}
